package com.ikun.controller;

import com.ikun.pojo.Result;
import com.ikun.service.BusinessService;
import com.ikun.service.impl.BusinessServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/business")
public class BusinessController {
    @Autowired
    BusinessService businessService;

    /**
     * 查询所有的商家
     * @param
     * @return  Result
     */
    @GetMapping("/getAllBusinesses")
    public Result getAllBusinesses(){
        return Result.success(businessService.getAllBusinesses());
    }
    /**
     * 获取商家详情
     * @param id
     * @return  Result
     */
    @GetMapping("/getBusinessById/{id}")
    public Result getBusinessById(@PathVariable("id") Integer id){
        return Result.success(businessService.getBusinessById(id));
    }
    /**
     * 根据classId获取商家列表
     * @param classId
     * @return  Result
     */
    @GetMapping("/getBusinessesByClassId")
    public Result getBusinessesByClassId(@RequestParam("classId") Integer classId){
        return Result.success(businessService.getBusinessesByClassId(classId));
    }

}
